using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class FriendsBUS
    {
        public static void Insert(tbFriends friend)
        {
            FriendsDAL frienddal = new FriendsDAL();
            frienddal.Insert(friend);
        }
        public static void Update(tbFriends friend)
        {
            FriendsDAL frienddal = new FriendsDAL();
            frienddal.Update(friend);
        }
        public static void Delete(int iD)
        {
            FriendsDAL frienddal = new FriendsDAL();
            frienddal.Delete(iD);
        }
        public static tbFriendcollection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            FriendsDAL frienddal = new FriendsDAL();
            return frienddal.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbFriends GetByID(int iD)
        {
            int t = 0;
            FriendsDAL frienddal = new FriendsDAL();
            tbFriendcollection Friendcollection = frienddal.GET("where " + tbFrienColumn.idbanbe.ToString() + " = " + iD.ToString(), 0, 0,
                tbFrienColumn.tenban.ToString(), "ASC", out t);
            if (Friendcollection.Count == 1)
                return Friendcollection[0];
            return null;
        }
        public static tbFriendcollection GetAll()
        {
            int t = 0;
            FriendsDAL friend= new FriendsDAL();
            return friend.GET("where 1=1", 0, 10,
                tbFrienColumn.idbanbe.ToString(), "ASC", out t);
        }
    }
}
